<template>
    <div>
    <el-table
            :data="pageData"
            style="width: 100%"
            :default-sort = "{prop: 'date', order: 'descending'}"

    >
        <el-table-column
                prop="userid"
                label="ID"
                sortable
                width="180">
        </el-table-column>
        <el-table-column
                prop="username"
                label="姓名"
                sortable
                width="180">
        </el-table-column>
        <el-table-column
                prop="userpass"
                label="密码"
                width="180">
        </el-table-column>
        <el-table-column
                prop="useropneid"
                label="openid"
                sortable
                :formatter="formatter">
        </el-table-column>

    </el-table>
        <el-pagination
            background
            layout="prev, pager, next"
            :total="(Math.ceil(this.tableData.length/6)*10)"
            @current-change="nexts"
        >
        </el-pagination>
    </div>
</template>

<script>
    import {AllUser} from "../../network/admin";

    export default {
        name: "Alluser",
        data() {
            return {
                tableData: [],
                pageData:[],
                currents:1
            }
        },
        methods: {
            formatter(row, column) {
                return row.address;
            },
            nexts(val){
                // console.log(current)
                val = val*6;
                this.pageData = this.tableData.slice(val-6,val)
            }
        },
        mounted() {
            AllUser(this.$store.state.auths).then(res => {
                if (res[0].userid > 0 ){
                    this.tableData = res;
                    console.log(this.tableData);
                    this.nexts(1)
                }
            })
        }
    }
</script>

<style scoped>

</style>
